package com.itboye.ihomebank.adapter;

import android.content.Context;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.bean.AdminKeyBean;
import com.itboye.ihomebank.support.commonadapter.MutiplyCommonAdapter;
import com.itboye.ihomebank.support.commonadapter.ViewHolder;

import java.util.List;
/**
 * 钥匙用户管理-白马锁
 */
public class AdminKeyAdapter  extends MutiplyCommonAdapter<AdminKeyBean.ListKey> {
    int position;
    List<AdminKeyBean.ListKey> datas;

    public AdminKeyAdapter(Context context, List<AdminKeyBean.ListKey> datas,
                               int... layoutId) {
        super(context, datas, layoutId);
        this.datas = datas;
    }

    @Override
    public int getItemViewType(int position) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void getItemPosition(int position) {
        this.position = position;

    }

    @Override
    public void convert(ViewHolder holder, AdminKeyBean.ListKey t, int type,
                        int position) {
      //  holder.setText(R.id.guanli_title, t.getUnick()+"("+t.getKey_id()+")");
  //   holder.setText(R.id.guanli_zhuangtai, t.getStatus().equals("110401")?"正常使用":"不能正常使用");
        if (t.getMark().equals("")){
            holder.setText(R.id.guanli_title, t.getUnick()+"");
        }else{
            holder.setText(R.id.guanli_title, t.getMark()+"");
        }
        try {
            holder.setText(R.id.guanli_zhuangtai, t.getKey_status());
            int startTime = Integer.parseInt(t.getStart());
            int endTime = Integer.parseInt(t.getEnd());
            if (startTime == 0 && endTime == 0) {
                holder.setText(R.id.guanli_leibie, t.getKey_type()+"（永久）");
            }else{
                holder.setText(R.id.guanli_leibie, t.getKey_type()+"（限时）");
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
    }

}
